module ProxyPump
  class ProxyTimeout

    attr_reader :connect, :read

    def initialize(options)
      options ||= {}
      @global   = options.fetch(:global, false)
      @read     = options.fetch(:read, 2)
      @connect  = options.fetch(:connect, 2)
    end

    def type
      global? ? :global : :per_operation
    end

    def global?
      !!@global
    end

    def per?
      !global?
    end

    def to_h
      { global: global?, type: type, connect: connect, read: read }
    end

  end # ProxyTimeout
end # ProxyPump
